Q: When NewPtr is used to allocate a block of memory in the application heap, is
it necessary to use DisposePtr to release this block when the program
terminates?
A: No. All memory allocated by an application in the application heap (with
NewPtr , NewHandle , NewPtrClear , or NewHandleClear ) is
released by the Process
Manager when the application terminates, and the application's heap zone is
destroyed. This means that you do not explicitly have to call DisposePtr to
release blocks of memory you allocate with a NewPtr call before the
application exits.
If your application allocates memory in the system heap, then it must
deallocate it. Otherwise, leaks occur. Calls that allocate memory in the system
heap include NewHandleSys , NewHandleSysClear , NewPtrSys , and NewPtrSysClear .
[May 01 1995]
|